define("aging",["islogin","jquery.cookie"],function (islogin) {
    islogin.islogin(function (res) {
        if(res.stu==1){
            sessionStorage.setItem("cartlist",JSON.stringify(res));
            sessionStorage.setItem("cartlist",JSON.stringify(res));
            var cookielist=JSON.parse($.cookie("cart") || '[]');
            var obj=[];
            if(cookielist!=null){
                cookielist.forEach(function (ele,index) {
                    console.log(ele);
                    obj.p_id=ele.p_id;
                    obj.p_name=ele.p_name;
                    obj.p_price=ele.p_price;
                    obj.p_size=ele.p_size;
                    obj.p_color=ele.p_color;
                    obj.gNum=ele.num;
                    obj.uId =res.data.uId;
                    obj.p_img=ele.p_img;


                })
                var data=new FormData();
                for(var key in obj)
                {
                    data.append(key,obj[key]);

                }
                $.ajax({
                    type:"post",
                    url:"../server/insertcart.php",
                    data:data,
                    dataType:"json",
                    processData:false,
                    contentType:false,
                })
                $.cookie("cart","",{expires:-1});

            }

        }
    })

})